<template>
	<div class="index">
		<driver-header
		 @addHandler = "addHandler"
		></driver-header>
		<driver-body
		   :DriverBody = "DriverBody"
		   :bottom = "bottom"
		   @addDriverBody = "getDriverBody"
		></driver-body>
	</div>
</template>

<script>
import DriverHeader from './DriverIndex/DriverHeader'
import DriverBody from './DriverIndex/DriverBody'
export default {
	name:"DriverMessage",
	components:{
			DriverHeader,
			DriverBody
		},
	data(){
		return{
			DriverBody: [],
			bottom: null,
			pages :1,
			rows : 15
		}
	},
	methods: {
		getDriverBody(page){
			this.pages=page
			var _this=this
			this.axios.get(`${this.baseURL}/driver/findPage`,{
				params:{
		      		pages: _this.pages,
					rows: _this.rows
		      	}
			}).then(res=>{
				res = res.data;
				if(res.status==200 && res.ok==true){
					const com=res.data
					const colcom=com.slice(com.length-1,com.length)
					const newcom=com.slice(0,com.length-1)
					_this.DriverBody=newcom
					this.bottom=colcom[0].countPage
				}
				console.log(_this.DriverBody);
			})
		},
		addHandler(Data){
			const com=Data
			const colcom=com.slice(com.length-1,com.length)
			const newcom=com.slice(0,com.length-1)
			this.DriverBody=newcom
			this.bottom=colcom[0].countPage
			console.log(Data);
		},
	},
	mounted(){
		this.getDriverBody()
	},
}
</script>

<style scoped>
    
</style>